-function(){
    function $(prap) {
        var typePrap = (typeof prap).toLowerCase();
        if (typePrap == 'function') {
            window.onload = prap;
        } else if (typePrap == 'string'||typePrap == 'object') {// 可能是$('.box') 也可能是 $(obox) 变量
            return new Init(prap);
        }
    };
    // extend 扩展
    $.extend = function (json) {
        if (json) {
            for (var key in json) {
                Init.prototype[key] = json[key];
            }
        }
    };
    // ajax 
    $.ajax = function (json) {
        var url = json.url || '',
            type = json.method || 'POST',
            aysn = json.aysn !== false,
            data = json.data || null,
            success = json.success || function(){},
            error = json.error || function(){};
        // 创建请求对象
        var xhr = null;
        if (XMLHttpRequest) {
            xhr = new XMLHttpRequest();
        } else {
            xhr = new ActiveVOject('Microsoft.XMLHttp');
        }
        // 处理数据
        var parcams = [];
        if (data) {
            for (var key in data) {
                parcams.push(key + '=' + data[key]);
            }
        }
        data = parcams.join('&');
        if (type.toUpperCase() === 'POST') {
            xhr.open(type,url,aysn);
            xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=utf-8');
            xhr.send(data);
        } else {
            xhr.open(type,url+'?'+data+'_='+new Date().getTime(),aysn);
            xhr.send();
        }
        // 请求
        xhr.onload = function () {
            if (this.readyState===4&&this.status>=200&&this.status<=300) {
                success && success(JSON.parse(this.response));
            } else {
                error && error(status);
            }
        }
    };
    // cookie 设置
    $.cookie = function () {
        var argus = arguments,
            leng = argus.length;
        if (leng == 2) {
           if ((typeof argus[0]).toLowerCase() == 'string') {
               return document.cookie = argus[0] + '=' + argus[1];
           }else if ((typeof argus[0]).toLowerCase() == 'object') {
               for (var key in argus[0]) {
                    return document.cookie = key + '=' + argus[0] + ';expires='+ new Date(new Date().getTime() + argus[1]*24*3600*1000);
               }
           }
        } else if (leng == 3 && argus[1] != undefined) {
            return document.cookie = argus[0] + '=' + argus[1] + ';expires=' + new Date(new Date().getTime()+argus[2]*24*3600*1000);
        }else{
            return document.cookie = argus[0] + '=' + argus[1] + ';expires=' + new Date(new Date().getTime()+argus[2]*24*3600*1000);
        }
    };
    // jquery对象
    function Init(prap) {
        this.length = this.init(prap);
    };
    Init.prototype = {
        // 获取jq对象
        init:function (prap) {
            var arr = [],
                Tprap = (typeof prap).toLowerCase();
            if (Tprap == 'object') {// 获取单一对象
                // 注意：getElementById()获取单个的有nodeName，而类似getElementsByClassName获取的是集合的没有nodeName(且为undefined)
                if (prap == window || prap.nodeType) {// window 和 内数组 节点类型为 undefined
                    arr[0] = prap;
                } else if (!isNaN(prap.length)) {// 获取类数组对象
                    var prapLeng = prap.length;
                    for (var i = 0; i < prapLeng; i++) {
                       arr[i] = prap[i];
                    }
                }
            } else if (Tprap == 'string') {
                arr = getDom(prap,[document]);
                /*var prapArr = prap.replace(/\s+/g,' ').replace(/^\s+|\s+$/g,'').split(' '),
                    lengParap = prapArr.length,
                    index = 0;
                arr = search(prapArr[0],[document]);// 第一次找是从 documen 开始
                function search(strDom,parentArr){ // 递归的方法 去找 如：找a $('#box p a')
                    var Leng = parentArr.length,
                        newArr = [];
                    for (var i = 0; i < Leng; i++) {
                       // 每次执行的时 getElement 返回一个数组,然后一次次拼接 [p] [p,p] [p,p,p] [p,p,p,p] 如此循环 parentArrLeng 长度次,然后返回一个整的数组
                       // i = 0 时,拼接一个 P 到 newArr 里 如：[p]
                       // console.log(newArr) [p] [p,p] [p,p,p] [p,p,p,p]
                       newArr = newArr.concat(getElement(strDom,parentArr[i]));// 可能很多个div 下面的 p 下面的 a,把有数组的对象全部拼接成一个数组
                    }
                    return index == lengParap-1?newArr:search(prapArr[++index],newArr);
                }
                function getElement(str,parent) {
                    var getArr = [];
                    if (str[0] == '#') { // id 方法
                        getArr[0] = document.getElementById(str.replace(/#/,''));
                    } else if (str[0] == '.') { // class 方法
                        if (parent.getElementsByClassName) {
                            var classArr = parent.getElementsByClassName(str.replace(/\./,'')),
                                cLeng = classArr.length;
                            for (var i = 0; i < cLeng; i++) {
                                getArr[i] = classArr[i];
                            }
                        } else {
                            var tagArr = parent.getElementsByTagName('*'),
                                tLeng = tagArr.length,
                                reg = new RegExp('(^|\\s)'+str.replace(/\./,'')+'(\\s|$)');
                           for (var i = 0; i < tLeng; i++) {
                               if (reg.test(tagArr[i].className)) {
                                getArr[i] = tagArr[i];
                               }
                           }
                        }
                    }else{ // Tag 方法
                        var TagArr = parent.getElementsByTagName(str),
                            Tleng = TagArr.length;
                        for (var i = 0; i < Tleng; i++) {
                            getArr[i] = TagArr[i];
                        }
                    } 
                    return getArr;
                }*/
            }
            var leng = arr.length;
            for (var i = 0; i < leng; i++) {
                this[i] = arr[i];
            }
            return arr.length;
        },
        // 遍历
        each:function(excel){
            for (var i = 0; i < this.length; i++) {
                excel.call(this[i],i);
            }
        },
        // jQ 对象转 js 对象
        get:function (num) {
            if (!isNaN(num)) {
                return this[parseInt(num)];
            }
        },
        // jQ 对象的选取
        eq:function (num) {
            if (!isNaN(num)) {
                return new Init(this[parseInt(num)]);// return $(this[num]) 也可以
            }
        },
        // index 获取对象的索引(下标)
        index:function (Index) {
            var typeIndex = (typeof Index).toLowerCase();
            if (typeIndex == 'undefined') {//无参数时,父级中的下标
                var siblings = this[0].parentNode.children,
                    leng = siblings.length;
                for (var i = 0; i < leng; i++) {
                    if (siblings[i] == this[0]) {//不管单个和多个都是返回第一个的下标
                        return i;
                    }
                }
            }else if (typeIndex == 'string') {//有参数时,同级中的下标
                var alls;
                if (new RegExp(/\./).test(Index)&&document.getElementsByClassName) {
                    Index = Index.replace('.','');
                    alls = this[0].parentNode.getElementsByClassName(Index);
                }else{
                    alls = this[0].parentNode.getElementsByTagName(Index);
                }
                var leng = alls.length;
                for (var i = 0; i < leng; i++) {
                    if (alls[i] == this[0]) {
                        return i;
                    }
                }
            }
        },
        // size 获取长度
        size:function () {
            return this.length;
        },
        // css 获取/设置 样式属性
        css:function () {
            var argu = arguments,
                leng = argu.length;
            if (leng == 2) {
                this.each(function() {
                    this.style[argu[0]] = argu[1];
                })
            }else if ((leng == 1)&&(typeof argu[0]).toLowerCase() === 'string') {
                //对象有很多时,只返回第一个的属性
                return getStyle(this[0],argu[0]);
            }else if ((leng == 1)&&(typeof argu[0]).toLowerCase() === 'object') {
                for (var key in argu[0]) {
                    this.each(function () {
                        this.style[key] = ((typeof argu[0][key]).toLowerCase() === 'number')&&(argu[0][key] + 'px')||argu[0][key];
                    })
                }
            };
            return this;
        },
        // width 宽度设置/获取
        width:function (num) {
            if (num) {
                this.css('width',(parseInt(num)==num)&&(num+'px')||num);
                return this;
            } else {
                return (this.css('width'));
            }
        },
        // height 高度设置/获取
        height:function (num){
            if (num) {
                this.css('height',(parseInt(num)==num)&&(num+'px')||num);
                return this;
            } else {
                return this.css('height');
            }
        },
        // innerWidth 获取盒子内部宽度(padding + 计算宽度)
        innerWidth:function () {
            return this[0].clientWidth;
        },
        // innerHeight 获取盒子内部高度(padding + 计算高度)
        innerHeight:function () {
            return this[0].clientHeight;
        },
        // outerWidth 获取盒子宽度(padding + border + 计算宽度)
        outerWidth:function () {
            return this[0].offsetWidth;
        },
        // outerHeight 获取盒子高度(padding + border + 计算高度)
        outerHeight:function () {
            return this[0].offsetHeight;
        },
        // offset 对象到文档的 left top 值
        offset:function () {
            var json = {top:0,left:0},
                This = this[0];//只返回第一个的 top left 值
            while(This !== document.body){
                json.top += This.offsetTop;
                json.left += This.offsetLeft;
                This = This.offsetParent;
            };
            return json;
        },
        // position 对象到定位父级的 top left 值
        position:function () {
            return {
                top:this[0].offsetTop,
                left:this[0].offsetLeft
            }
        },
        // scrollTop 上下滚动高度
        scrollTop:function (num) {
            if (num) {
                this.each(function () {
                    if (this === document) {
                        document.documentElement.scrollTop = Number(num);
                        document.body.scrollTop = Number(num);
                    } else {
                        this.scrollTop = Number(num);
                    }
                })
            } else {
                if (this[0] === document) {
                    return document.documentElement.scrollTop || document.body.scrollTop;
                } else {
                    return this[0].scrollTop;
                }
            }
        },
        // scrollLeft 左右滚动高度
        scrollLeft:function (num) {
            if (num) {
                this.each(function () {
                    if (this === document) {
                        document.documentElement.scrollLeft = Number(num);
                        document.body.scrollLeft = Number(num);
                    } else {
                        this.scrollLeft = Number(num);
                    }
                })
            } else {
                if (this[0] === document) {
                    return document.documentElement.scrollLeft || document.body.scrollLeft;
                } else {
                    return this[0].scrollLeft;
                }
            }
        },
        // innerHTML 的设置与获取
        html:function (HTML) {
            if (HTML != undefined) {
                this.each(function () {
                    this.innerHTML = HTML;// 相当于 this[i].innerHTML = HTML;
                });
                return this;
            }else{
                return this[0].innerHTML;
            }
        },
        // innerText 的设置与获取
        text:function (Text) {
            if (Text != undefined) {
                this.each(function () {
                    this.innerText = Text;
                });
                return this;
            }else{
                return this[0].innerText;
            }
        },
        // className 类名添加
        addClass:function (name) {
            if (name) {
                var splitArr = name.replace(/\s+/g,",").split(','),
                    leng = splitArr.length;
                for (var i = 0; i < leng; i++) {
                    this.each(function() {
                        var thisName = this.className,
                            reg = new RegExp('\\b'+splitArr[i]+'\\b');
                        if (reg.test(thisName)) {
                            return;
                        }else{
                            this.className&&(this.className += ' ' + splitArr[i])||(this.className = splitArr[i]);
                        }
                    })
                };
                return this;
            }
        },
        // removeClass 类名删除
        removeClass:function (name) {
            if (name) {
                var splitArr = name.replace(/\s+/g,',').split(','),
                    leng = splitArr.length;
                for (var i = 0; i < leng; i++) {
                    this.each(function () {
                        var thisName = this.className,
                            reg = new RegExp('\\b'+splitArr[i]+'\\b'),
                            repName = thisName.replace(reg,'');
                            // var regA = /^\s+|\s+$/; 去掉首尾空格
                            // var regB = /\s{2,}/g; 去掉中间2个以上的空格
                            // console.log(repName.replace(regA,'').replace(regB," "));
                            // repName.replace(regA,'').replace(regB," ")
                        this.className = repName.replace(/^\s+|\s{2,}|\s+$/g,'');
                    })
                }
            } else {
                this.each(function () {
                    this.className = '';
                })
            };
            return this;
        },
        // toggleClass 添加/删除类名
        toggleClass:function (name) {
            if (name) {
                var splitArr = name.replace(/\s+/g,',').split(','),
                    leng = splitArr.length;
                for (var i = 0; i < leng; i++) {
                    this.each(function () {
                        var thisName = this.className,
                            reg = new RegExp('\\b'+splitArr[i]+'\\b');
                        if (reg.test(thisName)) {
                            this.className = thisName.replace(reg,'').replace(/^\s+|\s{2,}|\s+$/g,'');
                        } else {
                            this.className&&(this.className += ' '+splitArr[i])||(this.className = splitArr[i]);
                        }    
                    })
                };
                return this;
            }
        },
        // hasClass 判断类名是否存在
        hasClass:function (name) {
            if (name) {
               var has = false;
               this.each(function () {
                    var splitName = name.replace(/\s+/g,''),
                        reg = new RegExp('(^|\\b)'+splitName+'(\\b|$)');
                    if (reg.test(this.className)) {
                        has = true;
                    } 
               });
               return has;
            }
        },
        // children 获取子元素
        children:function (dom) {
            var arr = [],
                str = '';
            if (dom) {
                var nDom = dom[0];
                if (nDom == '#') {
                    str = 'id';
                }else if (nDom == '.') {
                    str = 'className';
                }else{
                    str = 'nodeName';
                }
                var domName = dom.replace(/[#\.]/g,'');
                this.each(function () {
                    var child = this.children,
                        leng = child.length,
                        reg = new RegExp('(^|\\s)'+ domName +'(\\s|$)');
                    for (var i = 0; i < leng; i++) {
                        if (str == 'className') {
                            if (reg.test(child[i].className)) {
                                arr.push(child[i]);
                            }
                        }else{
                            if (child[i][str].toLowerCase() == domName) {
                                arr.push(child[i]);
                            }
                        }
                    }
                });
            } else {
                this.each(function () {
                    var child = this.children,
                        leng = child.length;
                    for (var i = 0; i < leng; i++) {
                        arr.push(child[i]);
                    }
                })
            }
            return new Init(arr);
        },
        // first 第一个子元素
        firstChild:function () {
            var arr = [];
            this.each(function () {
                !-[1,]?arr.push(this.firstChild):arr.push(this.firstElementChild);
            });
            return new Init(arr);
        },
        // last 最后一个子元素
        lastChild:function () {
            var arr = [];
            this.each(function () {
                !-[1,]?arr.push(this.lastChild):arr.push(this.lastElementChild);
            });
            return new Init(arr);
        },
        // insertBefore 插入节点
        insertBefore:function (dom){
            if (dom) {
                // var arr = getDom(dom,[document]),
                //     parent = arr[0].parentNode;
                // parent.insertBefore(this[0],parent.children[0]);
                var arr = new Init(dom),
                    parent = arr[0].parentNode;
                parent.insertBefore(this[0],arr[0]);
            }
            return this;
        },
        // append 往后面追加节点
        append:function (dom) {
            if (dom) {
                this.each(function () {
                   var parent = this.parentNode;
                       parent.appendChild(dom);
                });
            }
            return this;
        },
        // find 获取后代元素
        find:function (dom) {// find('#box p a')
            // getDom() 函数封装在 688 行
            return new Init(getDom(dom,this));
        },
        // parent 找父级
        parent:function () {
            var arr = [];
            this.each(function () {
                arr.push(this.parentNode);
            });
            return new Init(arr);
        },
        // parents 所有的父级
        parents:function () {
            var arr = [],
                html = document.getElementsByTagName('html')[0];
            this.each(function () {
                var parent = this;
                while(parent !== html){
                    parent = parent.parentNode;
                    arr.push(parent);
                }
            });
            return new Init(arr);
        },
        // siblings 找所有同级元素
        siblings:function (name) {
            var arr = [];
            if (name) {
                var nameDom = name.replace(/\s+/g,'');
                if (nameDom[0] == '#') {
                    this.each(function () {
                        var sibling = this.parentNode.children,
                            reg = new RegExp(nameDom.replace(/#/g,'')),
                            leng = sibling.length;
                        for (var i = 0; i < leng; i++) {
                            if (sibling[i] != this && reg.test(sibling[i].id)) {
                                arr.push(sibling[i]);
                            }
                        }
                    });
                }else if (nameDom[0] == '.') {
                    this.each(function () {
                        var sibling = this.parentNode.children,
                            reg = new RegExp(nameDom.replace(/\./g,'')),
                            leng = sibling.length;
                        for (var i = 0; i < leng; i++) {
                            if (sibling[i] != this && reg.test(sibling[i].className)) {
                                arr.push(sibling[i]);
                            }
                        }
                    });
                }else{
                    this.each(function () {
                        var sibling = this.parentNode.children,
                            leng = sibling.length;
                        for (var i = 0; i < leng; i++) {
                            if (sibling[i] != this && sibling[i].nodeName.toLowerCase() == nameDom) {
                                arr.push(sibling[i]);
                            }
                        }
                    });
                }
            } else {
                this.each(function () {
                    var sibling = this.parentNode.children,
                        leng = sibling.length;
                    for (var i = 0; i < leng; i++) {
                        if (sibling[i] != this) {
                            arr.push(sibling[i]);
                        }
                    }
                });
            }
            return new Init(arr);
        },
        // next 下一个元素
        next:function () {
            var arr = [];
            this.each(function () {
                var sibling = this.parentNode.children,
                    leng = sibling.length;
                for (var i = 0; i < leng; i++) {
                    if (sibling[i] == this) {
                        !-[1,]?arr.push(this.nextSibling):arr.push(this.nextElementSibling);
                    }
                }
            });
           return new Init(arr);
        },
        // prev上一个元素
        prev:function () {
            var arr = [];
            this.each(function () {
                var sibling = this.parentNode.children,
                    leng = sibling.length;
                for (var i = 0; i < leng; i++) {
                    if (sibling[i] == this) {
                        !-[1,]?arr.push(this.previousSibling):arr.push(this.previousElementSibling);
                    }
                }
            });
            return new Init(arr);
        },
        // attr 设置自定义属性
        attr:function () {
            var argu = arguments;
            if (argu.length == 2) {
                this.each(function () {
                    this.setAttribute(argu[0],argu[1]);
                })
            } else {
                var ArguType = (typeof argu[0]).toLowerCase();
                if (ArguType == 'object') {
                    for(var key in argu[0]){
                        this.each(function () {
                            this.setAttribute(key,argu[0][key]);
                        })
                    }
                } else if(ArguType == 'string'){
                    return this[0].getAttribute(argu[0]);
                }
            };
            return this;
        },
        // removeAttribute 移除属性
        removeAttr:function (key) {
            this.each(function () {
                this.removeAttribute(key);
            });
            return this;
        },
        // value 值获取与设置
        val:function(values){
            if (values != undefined) {
                this.each(function () {
                    this.value = values;
                });
                return this;
            } else {
                return this[0].value;
            }
        },
        // show 显示
        show:function () {
            var argus = arguments,
                leng = argus.length;
            if (leng) {
                var time,callback;
                for (var i = 0; i < leng; i++) {
                    if ((typeof argus[i]).toLowerCase() == 'number') {
                        time = argus[i];
                    } else if ((typeof argus[i]).toLowerCase() == 'function') {
                        callback = argus[i];
                    }
                }
                time = time || 600;
                this.each(function () {
                    var displayAttr = $(this).css('display'),
                        This = this;
                    if(displayAttr == 'none'){
                        var endWidth = parseInt($(this).width()),
                            endHeight = parseInt($(this).height()),
                            startWidth = 0,
                            startHeight = 0;
                        This.style.width = 0;
                        This.style.height = 0;
                        This.style.opacity = 0;
                        This.style.filter = 'alpha(opacity=0)';
                        This.style.display = 'block';
                        This.style.overflow = 'hidden';
                    }
                    var sTime = new Date();
                    ~function run(){
                        var prop = (new Date() - sTime)/time;
                        This.style.width = prop*(endWidth - startWidth) + 'px';
                        This.style.height = prop*(endHeight - startHeight) + 'px';
                        This.style.opacity = prop;
                        This.style.filter = 'alpha(opacity='+ prop*100 +')';
                        if (prop >= 1) {
                            cancelAnimationFrame(This.timer);
                            prop = 1;
                            This.style.overflow = 'visible';
                            callback && callback.call(This);
                        }else{
                            This.timer = requestAnimationFrame(run);
                        }
                    }();
                });
            } else {
                this.each(function () {
                    this.style.display = "block";
                });
            }
            return this;
        },
        // hide 隐藏
        hide:function () {
            var argus = arguments,
                leng = argus.length;
            if (leng) {
                var time,callback;
                for (var i = 0; i < leng; i++) {
                    if ((typeof argus[i]).toLowerCase() == 'number') {
                        time = argus[i];
                    } else if ((typeof argus[i]).toLowerCase() == 'function') {
                        callback = argus[i];
                    }
                }
                time = time || 600;
                this.each(function () {
                   var displayAttr = $(this).css('display'),
                       This = this; 
                    if (displayAttr == 'block') {
                        var startWidth = parseInt($(this).width()),
                            startHeight = parseInt($(this).height()),
                            endWidth = 0,
                            endHeight = 0;
                        This.style.overflow = 'hidden';
                        var date = new Date();
                        ~function run() {
                            var prop = (new Date() - date)/time;
                            This.style.width = (1 - prop)*startWidth + 'px';
                            This.style.height = (1 - prop)*startHeight + 'px';
                            This.style.opacity = 1 - prop;
                            This.style.filter = 'alpha(opacity='+ (1 - prop)*100 +')';
                            if (prop >= 1) {
                                cancelAnimationFrame(This.timer);
                                prop = 0;
                                callback && callback.call(This);
                            } else {
                                This.timer = requestAnimationFrame(run);
                            }
                        }();
                    }
                });
            } else {
                this.each(function () {
                    this.style.display = "none";
                });
            }
            return this;
        },
        // toggle 显示/隐藏
        toggle:function () {
            var argus = arguments,
                leng = argus.length;
            if (leng) {
                var time,callback;
                for (var i = 0; i < leng; i++) {
                    if ((typeof argus[i]).toLowerCase() == 'number') {
                        time = argus[i];
                    } else if ((typeof argus[i]).toLowerCase() == 'function') {
                        callback = argus[i];
                    }
                }
                time = time || 600;
                this.each(function () {
                    var displayAttr = $(this).css('display');
                    if (displayAttr == 'none') {
                        $(this).show(time,callback);
                    } else {
                        $(this).hide(time,callback);
                    }
                });
            } else {
                this.each(function () {
                    var displayAttr = $(this).css('display');
                    this.style.display = (displayAttr == 'none')?'block':'none';
                });
            }
            return this;
        },
        // fadeIn 淡入
        fadeIn:function(){
            var argus = arguments,
                leng = argus.length,
                time,
                callback,
                easing;
            for (var i = 0; i < leng; i++) {
                var Type = (typeof argus[i]).toLowerCase();
                switch(Type){
                    case 'number':
                        time = argus[i];
                        break;
                    case 'string':
                        if (argus[i] == 'slow'||'normal'||'fast') {
                            switch(argus[i]){
                                case 'slow':
                                    time = 800;
                                    break;
                                case 'normal':
                                    time = 600;
                                    break;
                                case 'fast':
                                    time = 400;
                                    break;
                            }
                        }else{
                            easing = argus[i];
                        }
                        break;
                    case 'function':
                        callback = argus[i];
                }
            };
            time || (time = 600);
            this.each(function () {
                var This = this,
                    sStart = getStyle(this,'opacity')||(String(getStyle(this,'filter')).replace(/\D/g,''))/100,// opacity 默认 1
                    sEnd = 1,
                    sTime = new Date();
                    
                if (getStyle(This,'display') == 'none') {
                    sStart = 0;
                    This.style.opacity = 0;
                    This.style.filter = 'alpha(opacity=0)';
                };
                This.style.display = 'block';
                ~function move(){
                    var prop = (new Date - sTime)/time,
                        t = parseInt(sStart) + prop*(sEnd - sStart);
                    This.style.opacity = t;
                    This.style.filter = 'alpha(opacity='+t*100+')';
                    if (prop >= 1) {
                        cancelAnimationFrame(This.timer);
                        prop = 1;
                        callback && callback.call(This);
                    } else {
                        This.timer = requestAnimationFrame(move);
                    }
                }();
            });
            return this;
        },
        // fadeOut 淡出
        fadeOut:function () {
            var argus = arguments,
                leng = argus.length,
                time,
                callback,
                easing;
            for (var i = 0; i < leng; i++) {
                var Type = (typeof argus[i]).toLowerCase();
                switch(Type){
                    case 'number':
                        time = argus[i];
                        break;
                    case 'string':
                        if (argus[i] == 'slow'||'normal'||'fast') {
                            switch(argus[i]){
                                case 'slow':
                                    time = 800;
                                    break;
                                case 'normal':
                                    time = 600;
                                    break;
                                case 'fast':
                                    time = 400;
                                    break;
                            }
                        }else{
                            easing = argus[i];
                        }
                        break;
                    case 'function':
                        callback = argus[i];
                }
            };
            time || (time = 600);
            this.each(function () {
                var This = this,
                    sStart = getStyle(This,'opacity')||1,// opacity 默认 1
                    sEnd = 0,
                    sTime = new Date();
                ~function move(){
                    var prop = (new Date - sTime)/time,
                        t = parseInt(sStart) + prop*(sEnd - sStart);
                    This.style.opacity = t;
                    This.style.filter = 'alpha(opacity='+t*100+')';
                    if (prop >= 1) {
                        cancelAnimationFrame(This.timer);
                        prop = 1;
                        This.style.display = 'none';
                        callback && callback.call(This);
                    } else {
                        This.timer = requestAnimationFrame(move);
                    }
                }();
            });
            return this;
        },
        // fadeToggle 淡入/淡出
        fadeToggle:function () {
            var argus = arguments,
                leng = argus.length;
            var time,callback,easing;
            if (leng) {
                for (var i = 0; i < leng; i++) {
                    var Type = (typeof argus[i]).toLowerCase();
                    switch(Type){
                        case 'number':
                            time = argus[i];
                            break;
                        case 'string':
                            if (argus[i] == 'slow'||'normal'||'fast') {
                                switch(argus[i]){
                                    case 'slow':
                                        time = 800;
                                        break;
                                    case 'normal':
                                        time = 600;
                                        break;
                                    case 'fast':
                                        time = 400;
                                        break;
                                }
                            } else {
                                easing = argus[i];
                            }
                            break;
                        case 'function':
                            callback = argus[i];
                            break;
                    }
                };
                time = time || 600;
                this.each(function () {
                    var displayAttr = $(this).css('display');
                    if (displayAttr == 'none') {
                        $(this).fadeIn(time,callback);
                    } else {
                        $(this).fadeOut(time,callback);
                    }
                });
            } else {
                this.each(function () {
                    var displayAttr = $(this).css('display');
                    if (displayAttr == 'none') {
                        $(this).fadeIn();
                    } else {
                        $(this).fadeOut();
                    }
                });
            }
            return this;
        },
        // slideDown 向下显示
        slideDown:function () {
            var argus = arguments,
                leng = argus.length;
            var time,callback;
            for (var i = 0; i < leng; i++) {
                var Type = (typeof argus[i]).toLowerCase();
                switch(Type){
                    case 'number':
                        time = argus[i];
                        break;
                    case 'function':
                        callback = argus[i];
                        break;
                }
            }
            time = time || 600;
            this.each(function () {
                var displayAttr = $(this).css('display');
                if (displayAttr == 'none') {
                    var endHeight = parseInt($(this).height()),
                        startHeight = 0,
                        This = this;
                    this.style.display = 'block';
                    this.style.height = 0;
                    this.style.overflow = 'hidden';
                    var sTime = new Date();
                    ~function run() {
                        var prop = (new Date() - sTime)/time;
                        This.style.height = prop*(endHeight - startHeight) + 'px';
                        if (prop >= 1) {
                            cancelAnimationFrame(This.timer);
                            prop = 1;
                            callback && callback.call(This);
                        } else {
                            This.timer = requestAnimationFrame(run);
                        }
                    }();
                }
            });
            return this;
        },
        // slideUp 向上隐藏
        slideUp:function () {
            var argus = arguments,
                leng = argus.length;
            var time,callback;
            for (var i = 0; i < leng; i++) {
                var Type = (typeof argus[i]).toLowerCase();
                switch(Type){
                    case 'number':
                        time = argus[i];
                        break;
                    case 'function':
                        callback = argus[i];
                        break;
                }
            }
            time = time || 600;
            this.each(function () {
                var displayAttr = $(this).css('display');
                if (displayAttr != 'none') {
                    var startHeight = parseInt($(this).height()),
                        endHeight = 0,
                        This = this;
                    This.style.overflow = 'hidden';
                    var sTime = new Date();
                    ~function run() {
                        var prop = (new Date() - sTime)/time;
                        This.style.height = -(endHeight - startHeight)*(1 - prop) + 'px';
                        if (prop >= 1) {
                            cancelAnimationFrame(This.timer);
                            prop = 1;
                            This.style.display = 'none';
                            callback && callback.call(This);
                        } else {
                            This.timer = requestAnimationFrame(run);
                        }
                    }();
                }
            });
            return this;
        },
        // slideToggle 显示/隐藏
        slideToggle:function () {
            var argus = arguments,
                leng = argus.length;
            var time,callback;
            for (var i = 0; i < leng; i++) {
                var Type = (typeof argus[i]).toLowerCase();
                switch(Type){
                    case 'number':
                        time = argus[i];
                        break;
                    case 'function':
                        callback = argus[i];
                        break;
                }
            }
            this.each(function () {
                var displayAttr = $(this).css('display');
                if (displayAttr == 'none') {
                    $(this).slideDown(time,callback);
                } else {
                    $(this).slideUp(time,callback);
                }
            });
            return this;
        },
        // animate 动画
        animate:function () {
            var argus = arguments,
                leng = argus.length;
            var endVal = argus[0];
            var time,callback,easing;
            for (var i = 1; i < leng; i++) {
                var Type = (typeof argus[i]).toLowerCase();
                switch(Type){
                    case 'number':
                            time = argus[i];
                            break;
                    case 'function':
                            callback = argus[i];
                            break;
                    case 'string':
                            easing = argus[i];
                            break;
                }
            }
            (time == 0)&&this.css(endVal);
            time = time || 200;
            this.each(function () {
                if (endVal) {
                    var starVal = {};
                    for (var key in endVal) {
                        starVal[key] = parseInt($(this).css(key));
                    }
                    var This = this;
                    var sTime = new Date();
                    ~function run() {
                        var prop = (new Date() - sTime)/time;
                        if (prop >= 1) {
                            cancelAnimationFrame(This.timer);
                            prop = 1;
                            callback && callback.call(This);
                        } else {
                            This.timer = requestAnimationFrame(run);
                        }
                        for (var key in endVal) {
                            This.style[key] = starVal[key] + prop*(parseInt(endVal[key]) - starVal[key]) + 'px';
                        }
                    }();
                }
            });
            return this;
        },
        // on 事件监听
        on:function (events,fn,Boolear) {
            this.each(function () {
                addEvent(this,events,fn,Boolear||false);
            });
            return this;
        },
        // off 事件解除
        off:function (events,fn){
            this.each(function () {
                removeEvent(this,events,fn);
            });
            return this;
        },
        // click 点击事件
        click:function (fn) {
            this.each(function () {
                this.onclick = fn;
            });
            return this;
        },
        hover:function () {
            var argus = arguments,
                leng = argus.length;
            if (leng == 1) {
                this.each(function () {
                    this.onmouseenter = argus[0];
                });
            } else if ( leng == 2){
                this.each(function () {
                    this.onmouseenter = argus[0];
                    this.onmouseleave = argus[1];
                });
            }
            return this;
        },
        // mouseenter 移入事件
        mouseenter:function (fn) {
            this.each(function () {
                this.onmouseenter = fn;
            });
            return this;
        },
        // mouseleave 移出事件
        mouseleave:function (fn) {
            this.each(function () {
                this.onmouseleave = fn;
            });
            return this;
        },
        // mousewheel 滚轮事件
        mousewheel:function (efn) {
            function fn(e) {
                e = e || window.event;
                var d = e.wheelDelta/120||-e.detail/3;
                if (efn.call(this,e,e.wheelDelta/120||-e.detail/3)===false) {
                    !-[1,]?e.returnValue=false:e.preventDefault();
                }
            }
            document.onmousewheel===null?this[0].onmousewheel = fn:addEvent(this[0],'DOMMouseScroll',fn,Boolear||false);
        },
        // mousedown 按下事件
        mousedown:function (fn) {
            this.each(function () {
                this.onmousedown = fn;
            });
            return this;
        },
         // mousemove 移动事件
        mousemove:function (fn) {
            this.each(function () {
                this.onmousemove = fn;
            });
            return this;
        },
        // mousedoup 抬起事件
        mouseup:function (fn) {
            this.each(function () {
                this.onmouseup = fn;
            });
            return this;
        },
        // focus 获取焦点事件
        focus:function (fn) {
            if (fn) {
                this.each(function () {
                    this.onfocus = fn;
                });
            } else {
                this.each(function () {
                    this.focus();
                });
            }
            return this;
        },
        // blur 失去焦点事件
        blur:function (fn) {
            if (fn) {
                this.each(function () {
                    this.onblur = fn;
                });
            } else {
                this.each(function () {
                    this.blur();
                });
            }
            return this;
        },
        // onkeypress 键盘事件
        keypress:function (fn) {
            this.each(function () {
                this.onkeypress = fn;
            })
        },
        // keyup 按下键盘抬起
        keyup:function (fn) {
            this.each(function () {
                this.onkeyup = fn;
            })
        },
    };
    // 获取类名对象封装
    function getDom(dom,obj){
        var getDomArr = [];
        var domArr = dom.replace(/\s+/g,' ').replace(/^\s+|\s+$/g,'').split(' '),
            leng = domArr.length,
            index = 0;
            
        getDomArr = search(domArr[0],obj);
        function search(strDom,parentArr){
            var len = parentArr.length,
                newArr = [];
            for (var i = 0; i < len; i++) {
                newArr = newArr.concat(getElement(strDom,parentArr[i]));
            }
            return index == leng - 1?newArr:search(domArr[++index],newArr);
        }
        function getElement(strDom,parent) {
            var getArr = [];
            if (strDom[0] == '#') {
                getArr[0] = document.getElementById(strDom.replace(/#/,''));
            }else if (strDom[0] == '.') {
                if (parent.getElementsByClassName) {
                    var classArr = parent.getElementsByClassName(strDom.replace(/\./,'')),
                        cLeng = classArr.length;
                    for (var i = 0; i < cLeng; i++) {
                        getArr[i] = classArr[i];
                    }
                }else{
                    var tagArr = parent.getElementsByTagName('*'),
                        tLeng = tagArr.length,
                        reg = new RegExp('(^|\\s)'+ strDom.replace(/\./,'') +'(\\s|$)');
                    for (var i = 0; i < tLeng; i++) {
                        if (reg.test(tagArr[i].className)) {
                            getArr.push(tagArr[i]);
                        }                            
                    }
                }
            }else{
                var TagArr = parent.getElementsByTagName(strDom),
                    Tagleng = TagArr.length;
                    for (var i = 0; i < Tagleng; i++) {
                        getArr[i] = TagArr[i];   
                    }
            }
            return getArr;
        }
        return getDomArr;
    };
    window.requestAnimationFrame = window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(fn){return setTimeout(fn,1000/60)};
    window.cancelAnimationFrame = window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||clearTimeout;
    function getStyle(obj,attr) {return !-[1,]?obj.currentStyle[attr]:getComputedStyle(obj)[attr];};
    function addEvent(obj,eName,efn,Boolear){!-[1,]?obj.attachEvent('on'+eName,efn,Boolear):obj.addEventListener(eName,efn,Boolear);};
    function removeEvent(obj,eName,efn){!-[1,]?obj.detachEvent('on'+eName,efn):obj.removeEventListener(eName,efn)};
    window.$ = window.xc = window.JS = window.XC = $;
}();